package com.jhinwins.equipmenteb.equipmentebserver.controller;

import com.alibaba.fastjson.JSONObject;
import com.jhinwins.equipmenteb.equipmentebserver.service.EvaluateService;
import com.jhinwins.equipmenteb.equipmentebserver.utils.RespUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("evaluate")
public class EvaluateController {

    private EvaluateService evaluateService;

    @Autowired
    public EvaluateController(EvaluateService evaluateService) {
        this.evaluateService = evaluateService;
    }

    @GetMapping
    public JSONObject evaluates(@RequestParam(name = "productid") Long productid) {
        return RespUtils.createSucResp(evaluateService.getEvaluates(productid));
    }
}
